import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), vueDevTools()],
  server: {
    host: 'localhost',
    // 代理
    proxy: {
      // 改为你的图片存储 url 前缀
      '/api-image': {
        target: 'https://jihui-picture-1320537828.cos.ap-shanghai.myqcloud.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api-image/, ''),
      },
    },
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
})
